home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / libraries / FAST / xpkFAST.a < prev    next >
Encoding:
Text File  |  1997-02-15  |  4.8 KB  |  159 lines

  1.     INCLUDE    AINCLUDE:IncDirs.i *sets all includedirs, needed for my ASM
  2.     INCLUDE    FAST/xpkLibFAST.i
  3.     include    "xpk/xpk.i"
  4.     include    "xpk/xpksub.i"
  5.     INCLUDE "exec/memory.i"
  6.  
  7.     INCLUDE    FAST/compress.a
  8.     INCLUDE    FAST/compress2.a
  9.     INCLUDE    FAST/decompress.a
  10.  
  11. ;    XREF    compress_fast
  12. ;    XREF    compress_slow
  13. ;    XREF    decompress
  14.  
  15. PACKMEM_FAST    equ    $10000
  16. PACKMEM_SLOW    equ    $44000
  17.  
  18. UNPACKMEM    equ    0
  19.  
  20. _XpksPackChunk:
  21.     movem.l a0-a6/d1,-(a7)
  22.     move.l    a6,a5            ; lib base
  23.     move.l    a0,a4            ; xparams
  24.  
  25.     move.l    xsp_Mode(a4),d1
  26.     
  27.     move.l    #PACKMEM_FAST,d0
  28.     lea.l    compress_fast(pc),a3
  29.  
  30.     cmp.l    #80,d1
  31.     bcs.s    IsFast
  32.     move.l    #PACKMEM_SLOW,d0
  33.     lea.l    compress_slow(pc),a3
  34. IsFast:
  35.     tst.l    xsp_Sub(a4)             ;Is there some memory allocated?
  36.     beq.s    AllocPackMem
  37.     cmp.l    xsp_Sub+4(a4),d0    ; Is the size right?
  38.     beq.s    packMemOK
  39.  
  40.     bsr.s    _XpksPackFree        ; Free currently allocated memory.
  41. AllocPackMem:
  42.     move.l    d0,xsp_Sub+4(a4)
  43.     move.l    #MEMF_PUBLIC,d1
  44.     move.l    4.W,a6
  45.     JSR    _LVOAllocMem(A6)
  46.     move.l    d0,xsp_Sub(a4)
  47.     bne.s    packMemOK
  48.     move.l    #XPKERR_NOMEM,d0
  49.     bra.s    endPackChunk
  50.  
  51. packMemOK:
  52.     move.l    xsp_InBuf(a4),a0        ;a0:=InBuf
  53.     move.l    xsp_OutBuf(a4),a1       ;a1:=OutBuf
  54.     move.l    xsp_Sub(a4),a2          ;a2:=Hash
  55.     move.l    xsp_InLen(a4),d0        ;d0:=InLen
  56.     moveq.l #90,d1
  57.     jsr    (a3)            ; call the compressor.
  58.     tst.l    d0
  59.     bne.s    Nooverrun
  60.     moveq.l #XPKERR_EXPANSION,d0
  61.     bra.s    endPackChunk
  62. Nooverrun:
  63.     move.l    d0,xsp_OutLen(a4)       ;Fill in Final output length XpkSubParams
  64.     moveq    #XPKERR_OK,d0
  65. endPackChunk:
  66.     movem.l (sp)+,a0-a6/d1
  67.     rts
  68.  
  69. _XpksPackFree:    movem.l a0-a2/a6/d0-d1,-(a7)
  70.         move.l    xsp_Sub(a0),a1
  71.         beq.s    packFreeEnd
  72.         clr.l    xsp_Sub(a0)
  73.         move.l    xsp_Sub+4(a0),d0    ; currently allocated amount.
  74.         clr.l    xsp_Sub+4(a0)
  75.         move.l    4.W,a6
  76.         JSR    _LVOFreeMem(A6)
  77. packFreeEnd:    movem.l (a7)+,a0-a2/a6/d0-d1
  78.         moveq    #XPKERR_OK,d0
  79.         rts
  80.  
  81. _XpksUnpackChunk:
  82.         move.l    a1,-(sp)
  83.         move.l    xsp_OutBuf(a0),a1
  84.         move.l    xsp_InLen(a0),d0
  85.         move.l    xsp_InBuf(a0),a0
  86.  
  87.         bsr    decompress
  88.         move.l    (sp)+,a1
  89.         moveq.l #XPKERR_OK,d0
  90.         rts
  91.  
  92.  
  93. _XpksPackerInfo:
  94.         move.l    a0,d0
  95.         lea    FastInfo(pc),a0
  96.         exg    a0,d0
  97.         rts
  98.  
  99.  
  100. ; --- Static Data --------
  101. FastInfo:
  102.  dc.w    1        ;xi_XpkInfoVersion:Version number of this structure
  103.  dc.w    VERSION     ;xi_LibVersion     : The version of this sublibrary
  104.  dc.w    2        ;xi_MasterVersion: The required master lib version
  105.  dc.w    0        ;xi_ModesVersion : Longword align
  106.  dc.l    FastName    ;xi_Name     : Brief name of the packer
  107.  dc.l    LongName    ;xi_LongName     : Full name of the packer
  108.  dc.l    Description    ;xi_Description  : One line description of packer
  109.  dc.b    'FAST'          ;xi_ID           : ID the packer goes by (XPK format)
  110.             ;xi_Flags     : Defined below
  111.  dc.l    XPKIF_PK_CHUNK|XPKIF_UP_CHUNK|XPKIF_MODES
  112.  dc.l    $7FFFFFFF    ;xi_MaxPkInChunk : Max input chunk size for packing
  113.  dc.l    0        ;xi_MinPkInChunk : Min input chunk size for packing
  114.  dc.l    $10000        ;xi_DefPkInChunk : Default packing chunk size
  115.  dc.l    PackMsg     ;xi_PackMsg     : Packing message, present tense
  116.  dc.l    UnpackMsg    ;xi_UnpackMsg     : Unpacking message, present tense
  117.  dc.l    PackedMsg    ;xi_PackedMsg     : Packing message, past tense
  118.  dc.l    UnpackedMsg    ;xi_UnpackedMsg  : Unpacking message, past tense
  119.  dc.w    50        ;xi_DefMode     : Default mode number
  120.  dc.w    0        ;xi_Pad      : for future use
  121.  dc.l    Modes        ;xi_Modes     : Array of compression modes
  122.  dc.l    0,0,0,0,0,0    ;xi_Reserved,6*4 : Future expansion - set to zero
  123.  
  124. FastName:    dc.b    'fasTcinator',0
  125. LongName:    dc.b    'FAST alias WOOP or LZRW++',0
  126. Description:    dc.b    'LZ77-family, windowsize: 4095, no quotecount, 2 streams',0
  127. PackMsg:    dc.b    'tieing',0
  128. PackedMsg:    dc.b    'compressed',0
  129. UnpackMsg:    dc.b    'untieing',0
  130. UnpackedMsg:    dc.b    'decompressed',0
  131.     EVEN
  132.  
  133. Modes:
  134.  dc.l    Crawling    ;xm_Next      : Chain to next descriptor for ModeDesc list
  135.  dc.l    79        ;xm_Upto      : Maximum efficiency handled by this mode.
  136.             ;xm_Flags      : Defined below
  137.  dc.l    XPKMF_A3000SPEED
  138.  dc.l    PACKMEM_FAST     ;xm_PackMemory      : Extra memory required during packing
  139.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  140.  dc.l    428        ;xm_PackSpeed      : Approx packing speed in K per second
  141.  dc.l    1055        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  142.  dc.w    327        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  143.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  144.  dc.b    'speedy',0,0,0,0 ;xm_Description,10:8 character mode description
  145.  
  146. Crawling:
  147.  dc.l    0        ;xm_Next      : Chain to next descriptor for ModeDesc list
  148.  dc.l    100        ;xm_Upto      : Maximum efficiency handled by this mode.
  149.             ;xm_Flags      : Defined below
  150.  dc.l    XPKMF_A3000SPEED
  151.  dc.l    PACKMEM_SLOW     ;xm_PackMemory      : Extra memory required during packing
  152.  dc.l    UNPACKMEM    ;xm_UnpackMemory  : Extra memory during unpacking
  153.  dc.l    70        ;xm_PackSpeed      : Approx packing speed in K per second
  154.  dc.l    1096        ;xm_UnpackSpeed   : Approx unpacking speed in K per second
  155.  dc.w    393        ;xm_Ratio      : CF in 0.1% for AmigaVision executable
  156.  dc.w    0        ;xm_ChunkSize      : Desired chunk size in K (!!) for this mode
  157.  dc.b    'crawling',0,0  ;xm_Description,10:8 character mode description
  158.     END
  159.